<template>
  <Common-Style>
    <h slot="title">近期 · 新闻</h>
    <div slot="body">
      <div class="list">
        <div class="ptbox">
          <a :href="'news/journalism/'+list[0].journalism.id">
            <div class="pic" :style="{backgroundImage:'url('+list[0].journalismPhotos[0].photoAddress+')'}">
              <div class="text"><p class="intro-wz">{{ list[0].journalism.journalismTitle }}</p></div>
            </div>
          </a>
        </div>
        <div class="box">
          <a :href="'news/journalism/'+item.journalism.id" class="abox" v-for="(item,index) in list" v-if="index<4" :key="item">
            <div class="item" :style="{backgroundImage:'url('+item.journalismPhotos[0].photoAddress+')'}">
              <div class="text"><p class="intro-wz">{{item.journalism.journalismTitle}}</p></div>
            </div>
          </a>
        </div>
      </div>
      <div class="el_button">
        <el-button @click="newsClick" type="primary" round>了解更多</el-button>
      </div>
    </div>
  </Common-Style>
</template>

<script>
// import CommonStyle from "./CommonStyle";
const CommonStyle = () => import('./CommonStyle')

export default {
  name: "HomeNews",
  data() {
    return {
      list:[]
    }
  },
  components: {
    CommonStyle
  },
  methods: {
    newsClick () {
      this.$router.push('/news');
    }
  },
  created: function () {
    console.log('我没了')
    // getma() {
    this.$nextTick(function () {
      this.$axios({
        url: '/officialwebsite/journalismFrontDesk/selectAll',
        method: 'get',
        // headers: {
        //   'X-CSRFToken': this.getCookie('csrftoken')
        // },
      }).then(res => {
        this.list = res.obj

      })
    })
  },


}
</script>

<style lang="less" scoped>
    .list {
      min-height: 500px;
      display: flex;
      flex-wrap:  wrap;
      justify-content: center;
      .ptbox{
        margin:10px auto 0;
        width: 690px;
        min-height: 500px;
        overflow: hidden;

        .pic {
            position: relative;
            width: 100%;
            height: 500px;
            overflow: hidden;
            background-position: center center;
            background-size: cover;
            transition: all 0.4s ease-out 0s;
            .text {
              position: absolute;
              width: 100%;
              left: 0;
              bottom: 1px;
              font-size: 25px;
              background: linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.9));
              .intro-wz {
                //超出部分隐藏
                overflow: hidden;
                //省略点
                text-overflow: ellipsis;
                //使文字不换行
                white-space: nowrap;
                padding: 0px 20px;
                //font-size: 20px;
                color: #fff;
                font-weight: 600;

              }
            }
          }
        .pic:hover {
          width: 150%;
          margin-left: -25%;
          .intro-wz {
            margin-left: 20%;
          }
        }
      }
      .box {
        text-align: center;
        margin:10px auto 0;
        width: 690px;
        min-height: 500px;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        .abox {
          height: 245px;
          width: 340px;
          margin:0px auto 10px;
        }
        .item {
          width: 100%;
          height: 100%;
          background-position: center center;
          background-size: cover;
          position: relative;
          transition: all 0.4s ease-out 0s;

          .text {
            position: absolute;
            width: 100%;
            left: 0;
            bottom: 0;
            background: linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.9));
            .intro-wz {
              font-size: 17px;
              font-weight: 600;
              color: #fff;
            }
          }

        }
        .item:hover {
          width: 110%;
          height: 110%;
          z-index: 99;
          margin-top: -2%;
          margin-left: -5%;
        }
      }
    }
    .el_button {
      margin-top: 30px;
      height: 40px;
      text-align: center;
    }
    @media screen and (max-width: 850px) {
      .ptbox{
        min-height: 200px!important;
      .pic {
        height: 60vw!important;
        .text {
          font-size: 14px!important;
        }
      }
      }
      .box {
        .abox {
          height: 50vw!important;
          margin: 0 auto;
          width: 100%!important;
          .text {
            .intro-wz {
              margin-left: 20px;
              text-align: left;
              font-size: 14px!important;
            }
          }
        }
      }
      .el-button {
        margin-top: -10px;
      }
    }

</style>
